import {get,post} from '../../utils/request'
const state={
    //用来保存查询出来的订单信息
    orders:[],
    total:0
  }
  
  const actions={
    //查询所有订单信息
    findAllOrder(context,list){
      //异步操作
      get('/order/pageQuery',list).then(res=>{
        let response=res.data.list
        context.commit('setOrder',response)
        let total=res.data.total
        context.commit('setTotal',total)
      })
    },
  
    //保存产品信息
    // saveOrder(context,list){       
    //   let respone=post('/product/saveOrUpdate',list)
    //   return respone
    // },
  
    //派单
    sendOrder(context,list){
        let respone=get('/order/sendOrder',list)
        return respone
      }
  }
  
  const mutations={
    //修改state中的值
    setOrder(state,response){
      state.orders=response
    },
    setTotal(state,total){
      state.total=total
    }
  }
  
  export default{
    namespaced:true,
    state,
    actions,
    mutations
  }